home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / support / mkdep / mkdep.ultrix < prev    next >
Encoding:
Text File  |  1989-01-24  |  1.8 KB  |  90 lines

  1. #!/bin/sh -
  2. #
  3. # Copyright (c) 1987 Regents of the University of California.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms are permitted
  7. # provided that the above copyright notice and this paragraph are
  8. # duplicated in all such forms and that any documentation,
  9. # advertising materials, and other materials related to such
  10. # distribution and use acknowledge that the software was developed
  11. # by the University of California, Berkeley.  The name of the
  12. # University may not be used to endorse or promote products derived
  13. # from this software without specific prior written permission.
  14. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15. # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16. # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17. #
  18. #    @(#)mkdep.sh    5.17 (Berkeley) 10/24/88
  19. #
  20. PATH=/bin:/usr/bin:/usr/ucb
  21. export PATH
  22.  
  23. D=.depend            # default dependency file is .depend
  24. append=0
  25.  
  26. while :
  27.     do case "$1" in
  28.         # -a appends to the depend file
  29.         -a)
  30.             append=1
  31.             shift ;;
  32.  
  33.         # -f allows you to select a makefile name
  34.         -f)
  35.             D=$2
  36.             shift; shift ;;
  37.  
  38.         # the -p flag produces "program: program.c" style dependencies
  39.         # so .o's don't get produced
  40.         -p)
  41.             SED='s;\.o;;'
  42.             shift ;;
  43.         *)
  44.             break ;;
  45.     esac
  46. done
  47.  
  48. if [ $# = 0 ] ; then
  49.     echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...'
  50.     exit 1
  51. fi
  52.  
  53. TMP=/tmp/mkdep$$
  54.  
  55. trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
  56.  
  57. # Ultrix has already (incorrectly) used -M for something else.
  58. cc -Em $* |
  59. sed "
  60.     s; \./; ;g
  61.     /\.c:$/d
  62.     $SED" |
  63. awk '{
  64.     if ($1 != prev) {
  65.         if (rec != "")
  66.             print rec;
  67.         rec = $0;
  68.         prev = $1;
  69.     }
  70.     else {
  71.         if (length(rec $2) > 78) {
  72.             print rec;
  73.             rec = $0;
  74.         }
  75.         else
  76.             rec = rec " " $2
  77.     }
  78. }
  79. END {
  80.     print rec
  81. }' > $TMP
  82.  
  83. if [ $append = 1 ]; then
  84.     cat $TMP >> $D
  85.     rm -f $TMP
  86. else
  87.     mv $TMP $D
  88. fi
  89. exit 0
  90.